package com.Cychat.post.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther: 崔航
 * @Date: 2025/10/28:14:28
 * @Description:rabbitmq路由模式配置
 */
@Configuration
public class RouteMQConfig {
    @Bean
    public Queue collectQueue(){
        return new Queue("cychat.collect");
    }
    @Bean
    public Queue likeQueue(){
        return new Queue("cychat.like");
    }
    @Bean
    public Queue commentQueue(){
        return new Queue("cychat.comment");
    }
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("cychat.exchange");
    }
    //绑定队列和交换机
    @Bean
    public Binding binding1(){
        return BindingBuilder.bind(collectQueue()).to(directExchange()).with("collect");
    }
    @Bean
    public Binding binding2(){
        return BindingBuilder.bind(likeQueue()).to(directExchange()).with("like");
    }
    @Bean
    public Binding binding3(){
        return BindingBuilder.bind(commentQueue()).to(directExchange()).with("comment");
    }
}